// mycomponent/ConnectCustomerService/DConnectCustomerService.js
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    zIndex: {
      type: Number,
      value: 2,
    },
    show: {
      type: Boolean,
      value: false,
    },
    qrcode: {
      type: String,
      value: null,
    },
    online: {
      type: String,
      value: "",
    },
    customer_open: {
      type: String || Number,
      value: null,
    },
    tel: {
      type: String,
      value: null,
    },
    goods_id:{
      type:String,
      value:null
    },
    goodsDetailId:{
      type:String,
      value:null
    },
    orderType:{
      type:null
    }
  },

  /**
   * 组件的初始数据
   */
  data: {},
  /**
   * 组件的方法列表
   */
  methods: {
    gotoChat(evt){
      console.log(evt,"evt===");
      // let url = evt.currentTarget.dataset.cservice + "&goods_id=" + this.data.goodsId; 
      let url = this.data.online
      if(this.data.goods_id){
        url = this.data.online + '&goods_id='+this.data.goods_id;
      }
      if(this.data.goodsDetailId){
        url += '&order_id='+this.data.goodsDetailId;
      }
      if(this.data.orderType){
        url += '&orderType='+this.data.orderType;
      }
      wx.navigateTo({
        url: url,
        fail: (err) => {
          app.tips("客服路由出错");
        }
      });
    },
    closePopup() {
      this.triggerEvent("closed");
      this.setData({
        show: false,
      });
    },
    phoneCall() {
      if (this.data.tel) {
        wx.makePhoneCall({
          phoneNumber: this.data.tel,
        });
      }
    },
  },
});